package com.yofeedy.actions;

import java.util.List;
import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.yofeedy.bean.UserFeeds;
import com.yofeedy.constants.ApplicationConstants;
import com.yofeedy.service.FeedService;

public class YoFeedyAction extends ActionSupport {

	private List<UserFeeds> userFeeds;

	private UserFeeds userFeed;

	public String submit() throws Exception {
		FeedService.getFeedService().saveUserFeeds(userFeed);
		display();
		return ApplicationConstants.SUCCESS;
	}

	public String execute() throws Exception {
		return display();
	}
	
	public String display() throws Exception {
		userFeeds = FeedService.getFeedService().getUserFeeds();
		Map<String, Object> session = ActionContext.getContext().getSession();
		session.put("userFeeds", userFeeds);
		return ApplicationConstants.SUCCESS;
	}

	public List<UserFeeds> getUserFeeds() {
		return userFeeds;
	}

	public void setUserFeeds(List<UserFeeds> userFeeds) {
		this.userFeeds = userFeeds;
	}

	public UserFeeds getUserFeed() {
		return userFeed;
	}

	public void setUserFeed(UserFeeds userFeed) {
		this.userFeed = userFeed;
	}

}
